package gem.model.dao;


// Represents entity from database
public class Course
{
	//-----------------------------------------------------------------------------------//
	private String m_CourseTitle;
	private int m_CourseId;
	//-----------------------------------------------------------------------------------//
	private ScienceDomain m_ScienceDomain;
	//-----------------------------------------------------------------------------------//
	protected Course setScienceDomain( ScienceDomain s )
	{
		if( m_ScienceDomain != null )
		{
			m_ScienceDomain.removeCourse( this );
		}
		
		m_ScienceDomain = s;
		return this;
	}
	//-----------------------------------------------------------------------------------//
	public ScienceDomain getScienceDomain() { return m_ScienceDomain; }
	//-----------------------------------------------------------------------------------//
	public String getTitle() { return m_CourseTitle; }
	public Course setTitle( String title ) { m_CourseTitle = title; return this; }
	//-----------------------------------------------------------------------------------//
	public int getId() { return m_CourseId; }
	public Course setId( int id ) { m_CourseId = id; return this; }
	//-----------------------------------------------------------------------------------//
	//-----------------------------------------------------------------------------------//
	//-----------------------------------------------------------------------------------//
	@Override
	public int hashCode()
	{
		return getTitle().hashCode();
	}
	//-----------------------------------------------------------------------------------//
	@Override
	public boolean equals(Object obj)
	{
		if( obj instanceof Course == false )
		{
			return false;
		}
		if( this == obj )
		{
			return true;
		}
		Course temp = (Course)obj;
		
		return ( (temp.getId() == this.getId()) && (temp.getTitle().equals(this.getTitle())) );
	}
	//-----------------------------------------------------------------------------------//
	@Override
	public String toString()
	{
		// TODO Auto-generated method stub
		return m_CourseTitle;
	}
}
